package io.dshubs.archives.controller;


import io.dshubs.archives.service.ArchiveHomeService;
import io.dshubs.commons.log.annotation.LogOperation;
import io.dshubs.commons.tools.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 * 我的收藏
 * </p>
 *
 * @author tan
 * @since 2021-08-27
 */
@Api(tags = "我的收藏")
@RestController
@RequestMapping("/home")
public class ArchiveHomeController {

    @Autowired
    private ArchiveHomeService archiveHomeService;


    @GetMapping("statistics")
    @ApiOperation("统计总数")
    @LogOperation("统计总数")
    public Result<Map<String, Object>> statistics(){
        Map resultMap = new HashMap();

        int destroyCount = archiveHomeService.selectArchiveDestroyCount();
        resultMap.put("destroyCount", destroyCount);


        int waitForReturnCount = archiveHomeService.selectWaitForReturnCount();
        resultMap.put("waitForReturnCount", waitForReturnCount);


        int borrowOutTimeCount = archiveHomeService.selectBorrowOutTimeCount();
        resultMap.put("borrowOutTimeCount", borrowOutTimeCount);


        int nearOutTimeCount = archiveHomeService.selectBorrowNearOutTimeCount();
        resultMap.put("nearOutTimeCount", nearOutTimeCount);

        return new Result<Map<String, Object>>().ok(resultMap);
    }
}
